<template>
  <!--符合性审查项汇总表-->
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <a-table
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        class="j-table-force-nowrap"
      >
      </a-table>
    </div>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getAction, postAction } from '@api/manage'
export default {
  name: 'FhxDetail',
  components: {},
  props: {
    bidSectionId: {},
    businessId: {},
  },
  data() {
    return {
      description: '符合性明细',
      loading: false,
      // 表头
      columns: [],
      url: {
        // 符合性审查项评分记录,
        getConformanceReviewRecord: '/exPingbiao/exPingbiaoExpertRecord/getConformanceReviewRecord',
      },
      dataSource: {},
      tenderListData: [], //投标人
    }
  },
  watch: {
    businessId: {
      immediate: true,
      handler(val) {},
    },
  },
  created() {},
  computed: {},
  methods: {
    initColumns() {
      this.columns = [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '审查项',
          align: 'center',
          dataIndex: 'reviewItem',
        },
        {
          title: '审查标准',
          align: 'center',
          dataIndex: 'reviewStandard',
        },
      ]
    },
    loadData(businessId) {
      var that = this
      let params = {
        conformanceReviewId: businessId,
      }
      that.loading = true
      getAction(this.url.getConformanceReviewRecord, params)
        .then((res) => {
          if (res.success) {
            var list = res.result.conformanceReviewDetailList
            that.tenderListData = res.result.exTenderLists //投标人
            that.initColumns()
            for (let i = 0; i < that.tenderListData.length; i++) {
              const element = that.tenderListData[i]
              this.columns.push({
                align: 'center',
                title: element.bidderName,
                dataIndex: 'tbr_' + element.id,
              })
            }
            for (let j = 0; j < list.length; j++) {
              var reviewItem = list[j]
              that.tenderListData.forEach((element) => {
                reviewItem['tbr_' + element.id] = that.getScore(reviewItem, element.id)
              })
            }
            that.dataSource = list
          }
        })
        .finally(() => {
          that.loading = false
        })
    },
    getScore(reviewItem, tenderListId) {
      let find = reviewItem.sumList.find((find) => find.tenderListId == tenderListId)
      if (find) {
        return find.passNumber + '√ ' + find.failNumber + 'x'
      }
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>